package com.ttw;

import android.accounts.Account;
import android.content.AbstractThreadedSyncAdapter;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SyncResult;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;

public class SyncAdapter extends AbstractThreadedSyncAdapter {
    private static final String b = "TTW";

    Context f2483a;

    class a implements Runnable {

        final Account f2484a;

        a(Account account) {
            this.f2484a = account;
        }

        public void run() {
            Bundle bundle = new Bundle();
            bundle.putBoolean("expedited", true);
            bundle.putBoolean("force", true);
            bundle.putBoolean("reset", true);
            ContentResolver.requestSync(this.f2484a,  AccountApi.CONTENT_AUTHORITY, bundle);
        }
    }

    public SyncAdapter(Context context, boolean z) {
        super(context, z);
        this.f2483a = context;
        
    }

    public void onPerformSync(Account account, Bundle bundle, String str, ContentProviderClient contentProviderClient, SyncResult syncResult) {
        
        if (bundle.getBoolean("reset")) {
                
            syncResult.stats.numIoExceptions = 0;
            Bundle bundle2 = new Bundle();
            bundle2.putBoolean("expedited", true);
            bundle2.putBoolean("force", true);
            bundle2.putBoolean("reset", false);
            ContentResolver.requestSync(account, AccountApi.CONTENT_AUTHORITY, bundle2);
            return;
        }
        syncResult.stats.numIoExceptions = 1;
        new Handler(Looper.getMainLooper()).postDelayed(new a(account), 15000);

    }

}
